package com.xnew.utils;

import java.text.ParseException;
import java.util.Date;

public class XmlUtil {

	public static final String ORIGINSYSID = "KHGXJT01";
	public static final String INSYSID = "KHGXJT01";
	public static final String CHANNELID = "000";
	public static final String ORGNO = "000001";

	/**
	 * xml报文头
	 * @param msgHeader
	 * @return
	 */
	public static MsgHeader creatMsgHeader(MsgHeader msgHeader) {
		try {
			String UUID = IdUtils.getRandomIdByUUID();
			msgHeader.setTellerId("");
			msgHeader.setRespCode("");
			msgHeader.setOriginSysId(ORIGINSYSID);
			msgHeader.setRespSerialNo("");
			msgHeader.setInSysId(INSYSID);
			msgHeader.setChannelId(CHANNELID);
			msgHeader.setOrgNo(ORGNO);
			msgHeader.setTerminalNo("");
			msgHeader.setUUID(UUID);
			msgHeader.setRespType("");
			msgHeader.setVersion(msgHeader.getVersion());
			msgHeader.setServiceName(msgHeader.getServiceName());
			msgHeader.setSerialNo(UUID);
			msgHeader.setRequestTime(DateUtils.dateFormat(new Date(), "HHmmss"));
			msgHeader.setRequestDate(DateUtils.dateFormat(new Date(), "yyyyMMdd"));
			msgHeader.setRespCodeDec("");
			msgHeader.setMethodName(msgHeader.getMethodName());
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return msgHeader;
	}
	
	/**
	 * xml报文体
	 * @param msgBody
	 * @return
	 */
	public static MsgBody creatMsgBody(MsgBody msgBody) {
		return msgBody;
	}
	
	public static Msg createMsg(MsgHeader msgHeader,MsgBody msgBody) {
		Msg msg = new Msg();
		msg.setMsgBody(msgBody);
		msg.setMsgHeader(msgHeader);
		return msg;
	}
}
